import sqlite3
conn=sqlite3.connect(r"fish2.db")
cur=conn.cursor()
cur.execute('''CREATE TABLE IF NOT EXISTS users
            (id TEXT NOT NULL,
            name TEXT NOT NULL,
            habit TEXT);''')
conn.commit()
cur.execute(f"INSERT INTO users(id,name,habit) VALUES('f1','鲤鱼','杂食性')")
cur.execute(f"INSERT INTO users(id,name,habit) VALUES('f2','草鱼','食草性')")
cur.execute(f"INSERT INTO users(id,name,habit) VALUES('f3','鲫鱼','温水性')")
cur.execute(f"INSERT INTO users(id,name,habit) VALUES('f4','鳙鱼','温水性')")
cur.execute(f"INSERT INTO users(id,name,habit) VALUES('f5','黑鱼','肉食性')")
conn.commit()
cur.execute("SELECT * FROM users")
result = cur.fetchall()
for i in result:
    print(i,end='\n')
conn.commit()
conn.close()

import pymysql

conn2=pymysql.connect(host='localhost',user='root',password='123456',database='fish',charset='utf8')
cur2=conn2.cursor()
sql="select * from fish1;"
cur2.execute("select * from fish1")
fishl=cur2.fetchall()
for j in fishl:
    print(j)
cur2.close()
conn2.close()